﻿<phoneNavigation:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phoneNavigation="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:pb="clr-namespace:Spritehand.PhysicsBehaviors;assembly=Spritehand.PhysicsBehaviors" 
    x:Class="ApplyTorqueDemo.MainPage"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}">
	<phoneNavigation:PhoneApplicationPage.Resources>
		<SolidColorBrush x:Key="brushGreen" Color="#FF318052"/>
	</phoneNavigation:PhoneApplicationPage.Resources>

    <Grid x:Name="LayoutRoot" Background="{StaticResource PhoneBackgroundBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Canvas x:Name="cnvGame" Grid.Row="1" Background="White">
        	<i:Interaction.Behaviors>
        		<pb:PhysicsControllerBehavior MousePickEnabled="False"/>
        	</i:Interaction.Behaviors>

        	<Ellipse x:Name="ball" CacheMode="BitmapCache" Height="54" Canvas.Left="206" StrokeStartLineCap="Flat" StrokeEndLineCap="Flat" StrokeThickness="1" StrokeMiterLimit="10" StrokeLineJoin="Miter" Canvas.Top="134" Width="55">
        		<Ellipse.Fill>
        			<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
        				<GradientStop Color="#FFD06458" Offset="0.491"/>
        				<GradientStop Color="#FF6D6DB8" Offset="0.513"/>
        			</LinearGradientBrush>
        		</Ellipse.Fill>
        		<i:Interaction.Triggers>
        			<pb:PhysicsKeyTrigger Key="Right">
        				<pb:PhysicsApplyTorqueBehavior TorqueValue="5000"/>
        			</pb:PhysicsKeyTrigger>
        			<pb:PhysicsKeyTrigger Key="Left">
        				<pb:PhysicsApplyTorqueBehavior TorqueValue="-5000"/>
        			</pb:PhysicsKeyTrigger>
        		</i:Interaction.Triggers>
        		<i:Interaction.Behaviors>
        			<pb:PhysicsObjectBehavior />
        		</i:Interaction.Behaviors>
        	</Ellipse>
            <Path CacheMode="BitmapCache" Data="M108.5,169.5 C116.00001,174.00021 353,177 359,166.5 C365,156 375.49976,109.49769 359,119.99873 C350.51138,125.40118 122.00032,127.49858 113.00032,118.49832 C104.00031,109.49806 100.99999,164.99979 108.5,169.5 z" Fill="{StaticResource brushGreen}" Height="57.11" Canvas.Left="103.749" StrokeStartLineCap="Flat" Stretch="Fill" StrokeEndLineCap="Flat" StrokeThickness="1" StrokeMiterLimit="10" StrokeLineJoin="Miter" Canvas.Top="184.515" UseLayoutRounding="False" Width="264.607">
        		<i:Interaction.Behaviors>
        			<pb:PhysicsObjectBehavior IsStatic="True"/>
        		</i:Interaction.Behaviors>
        	</Path>
            <Path CacheMode="BitmapCache" Data="M108.5,169.5 C116.00001,174.00021 353,177 359,166.5 C365,156 375.49976,109.49769 359,119.99873 C350.51138,125.40118 122.00032,127.49858 113.00032,118.49832 C104.00031,109.49806 100.99999,164.99979 108.5,169.5 z" Fill="{StaticResource brushGreen}" Height="57.11" Canvas.Left="16" StrokeStartLineCap="Flat" Stretch="Fill" StrokeEndLineCap="Flat" StrokeThickness="1" StrokeMiterLimit="10" StrokeLineJoin="Miter" Canvas.Top="370.515" UseLayoutRounding="False" Width="161">
        		<i:Interaction.Behaviors>
        			<pb:PhysicsObjectBehavior IsStatic="True"/>
        		</i:Interaction.Behaviors>
        	</Path>
            <Path CacheMode="BitmapCache" Data="M108.5,169.5 C116.00001,174.00021 353,177 359,166.5 C365,156 375.49976,109.49769 359,119.99873 C350.51138,125.40118 122.00032,127.49858 113.00032,118.49832 C104.00031,109.49806 100.99999,164.99979 108.5,169.5 z" Fill="{StaticResource brushGreen}" Height="57.11" Canvas.Left="304.893" StrokeStartLineCap="Flat" Stretch="Fill" StrokeEndLineCap="Flat" StrokeThickness="1" StrokeMiterLimit="10" StrokeLineJoin="Miter" Canvas.Top="370.515" UseLayoutRounding="False" Width="158.107">
        		<i:Interaction.Behaviors>
        			<pb:PhysicsObjectBehavior IsStatic="True"/>
        		</i:Interaction.Behaviors>
        	</Path>
            <Path CacheMode="BitmapCache" Data="M108.5,169.5 C116.00001,174.00021 353,177 359,166.5 C365,156 375.49976,109.49769 359,119.99873 C350.51138,125.40118 122.00032,127.49858 113.00032,118.49832 C104.00031,109.49806 100.99999,164.99979 108.5,169.5 z" Fill="{StaticResource brushGreen}" Height="57.11" Canvas.Left="103.749" StrokeStartLineCap="Flat" Stretch="Fill" StrokeEndLineCap="Flat" StrokeThickness="1" StrokeMiterLimit="10" StrokeLineJoin="Miter" Canvas.Top="577.515" UseLayoutRounding="False" Width="264.607">
        		<i:Interaction.Behaviors>
        			<pb:PhysicsObjectBehavior IsStatic="True" RestitutionCoefficient="1.4"/>
        		</i:Interaction.Behaviors>
        	</Path>
            <Path x:Name="star" CacheMode="BitmapCache" Data="M326,655 L324.5,623.5 L344,644.5 L380,641.5 L360.5,662.5 L383,682 L351.5,679 L335,712 L333.5,674.5 L306.5,679 z" Fill="#FFE0D330" Height="89.5" Canvas.Left="346.5" StrokeStartLineCap="Flat" Stretch="Fill" StrokeEndLineCap="Flat" Stroke="Black" StrokeThickness="1" StrokeMiterLimit="10" StrokeLineJoin="Miter" Canvas.Top="674.5" UseLayoutRounding="False" Width="77.5">
        		<i:Interaction.Triggers>
        			<pb:PhysicsCollisionTrigger BodyOne="ball" BodyTwo="star">
        				<pb:PhysicsExplodeBehavior DeactivateBody="True" NumParticles="10"/>
        			</pb:PhysicsCollisionTrigger>
        		</i:Interaction.Triggers>
        		<i:Interaction.Behaviors>
        			<pb:PhysicsObjectBehavior RestitutionCoefficient="1.5"/>
        		</i:Interaction.Behaviors>
        	</Path>
            <Rectangle CacheMode="BitmapCache" Fill="{StaticResource brushGreen}" StrokeStartLineCap="Flat" StrokeEndLineCap="Flat" StrokeThickness="1" StrokeMiterLimit="10" StrokeLineJoin="Miter" Width="71" d:LayoutOverrides="VerticalAlignment, GridBox" Height="800" Canvas.Left="-59">
        		<i:Interaction.Behaviors>
        			<pb:PhysicsObjectBehavior IsStatic="True"/>
        		</i:Interaction.Behaviors>
        	</Rectangle>
            <Rectangle CacheMode="BitmapCache" Fill="{StaticResource brushGreen}" StrokeStartLineCap="Flat" StrokeEndLineCap="Flat" StrokeThickness="1" StrokeMiterLimit="10" StrokeLineJoin="Miter" Width="71" d:LayoutOverrides="VerticalAlignment, GridBox" Height="800" Canvas.Left="467">
        		<i:Interaction.Behaviors>
        			<pb:PhysicsObjectBehavior IsStatic="True"/>
        		</i:Interaction.Behaviors>
        	</Rectangle>
            <Rectangle CacheMode="BitmapCache" Fill="{StaticResource brushGreen}" StrokeStartLineCap="Flat" StrokeEndLineCap="Flat" StrokeThickness="1" StrokeMiterLimit="10" StrokeLineJoin="Miter" d:LayoutOverrides="GridBox" Height="62" VerticalAlignment="Bottom" Canvas.Left="-59" Canvas.Top="782" Width="597">
        		<i:Interaction.Behaviors>
        			<pb:PhysicsObjectBehavior IsStatic="True"/>
        		</i:Interaction.Behaviors>
        	</Rectangle>
        	<TextBlock Height="127" Canvas.Left="16" TextWrapping="Wrap" Text="Get the ball to the star. Tilt the device to apply torque. In the emulator you can click and drag in the window or use the left and right arrow keys." Width="447" Foreground="#FF318052" FontSize="24" Canvas.Top="13" />
        </Canvas>

    </Grid>
    
</phoneNavigation:PhoneApplicationPage>